package com.ruoyi.yuan.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yuan.domain.Star;
import com.ruoyi.yuan.service.IStarService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 星球信息Controller
 * 
 * @author guifeng
 * @date 2022-08-24
 */
@Api("星球信息")
@RestController
@RequestMapping("/yuan/star")
public class StarController extends BaseController
{
    @Autowired
    private IStarService starService;

    /**
     * 查询星球信息列表
     */
    @ApiOperation("查询星球信息列表")
    @PreAuthorize("@ss.hasPermi('yuan:star:list')")
    @GetMapping("/list")
    public AjaxResult list(Star star)
    {
        List<Star> list = starService.selectStarList(star);
        return AjaxResult.success(list);
    }

    /**
     * 导出星球信息列表
     */
    @ApiOperation("导出星球信息列表")
    @PreAuthorize("@ss.hasPermi('yuan:star:export')")
    @Log(title = "星球信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Star star)
    {
        List<Star> list = starService.selectStarList(star);
        ExcelUtil<Star> util = new ExcelUtil<Star>(Star.class);
        util.exportExcel(response, list, "星球信息数据");
    }

    /**
     * 获取星球信息详细信息
     */
    @ApiOperation("获取星球信息详细信息")
    @PreAuthorize("@ss.hasPermi('yuan:star:query')")
    @GetMapping(value = "/{starId}")
    public AjaxResult getInfo(@PathVariable("starId") Long starId)
    {
        return AjaxResult.success(starService.selectStarByStarId(starId));
    }

    /**
     * 新增星球信息
     */
    @ApiOperation("新增星球信息")
    @PreAuthorize("@ss.hasPermi('yuan:star:add')")
    @Log(title = "星球信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Star star)
    {
        return toAjax(starService.insertStar(star));
    }

    /**
     * 修改星球信息
     */
    @ApiOperation("修改星球信息")
    @PreAuthorize("@ss.hasPermi('yuan:star:edit')")
    @Log(title = "星球信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Star star)
    {
        return toAjax(starService.updateStar(star));
    }

    /**
     * 删除星球信息
     */
    @ApiOperation("删除星球信息")
    @PreAuthorize("@ss.hasPermi('yuan:star:remove')")
    @Log(title = "星球信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{starIds}")
    public AjaxResult remove(@PathVariable Long[] starIds)
    {
        return toAjax(starService.deleteStarByStarIds(starIds));
    }
}
